# -*- coding:utf-8 -*-

import pymongo


class mongo(object):
    def __init__(self, uri):
        self.client = pymongo.MongoClient("localhost", 27017)
        self.db = self.client["RWLS_log"]
        self.collections = {
            "debug": self.db["debug"],
            "info": self.db["info"],
            "warn": self.db["warn"],
            "error": self.db["error"]
        }

    def find(self, *args):
        return self.collections[level].find(data)

    def find_one(self, arg):
        return self.collections[level].find(data)

    def save(self, data):
        self.collections[level].save(data)

    def insert(self, args):
        self.collections[args[0]].insert(args[1])

    def update(self, data):
        self.collections[level].update(data)

    def remove(self, data):
        self.collections[level].remove(data)
